package com.human.controller;


import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.human.entity.Contract;
import com.human.entity.ResultVo;
import com.human.service.IContractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author jzq
 * @since 2023-03-05
 */
@RestController
@RequestMapping("/api/contract")
@Api(tags = "合同管理")
@ApiSupport(order = 3)
public class ContractController {

    @Autowired
    IContractService contractService;

    @PostMapping("/page")
    @ApiOperation(value = "合同分页查询")
    public ResultVo page(int current, int pageSize, String name) {
        return contractService.page(current, pageSize, name);
    }

    @GetMapping("/contractList")
    @ApiOperation(value = "查询所有合同")
    public ResultVo getContracts(){
        return contractService.getContracts();
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "根据ID查询合同")
    public ResultVo getContractById(@PathVariable("id") Integer id){
        return contractService.getContractById(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "根据ID删除合同")
    public ResultVo deleteContractById(@PathVariable("id") Integer id){
        return contractService.deleteContractById(id);
    }

    @PostMapping("/addContract")
    @ApiOperation(value = "添加合同")
    public ResultVo addContract(@RequestBody Contract contract){
        return contractService.addContract(contract);
    }

    @PutMapping("/updateContract")
    @ApiOperation(value = "修改合同")
    public ResultVo updateContract(@RequestBody Contract contract){
        return contractService.updateContract(contract);
    }




}

